%
% Depricated
%
function c = fuzzy_centroid1(x)

N = length(x);

% delta alpha 
da = 1/(6 * (N-1));

% delta left 
dl = x(2:end,1) - x(1:end-1,1);

% delta right
dr = x(1:end-1,2) - x(2:end,2);

% indices
index = [1:N-1].';

%modified indices
m_index = 3 .* index - 2;


% weighted integral of the left function
l_term = dl.' * (x(2:end,1) + (x(2:end,1) + x(1:end-1,1)) .* m_index);

% weighted integral of the right function
r_term = dr.' * (x(2:end,2) + (x(2:end,2) + x(1:end-1,2)) .* m_index);

% weighted area of the peak
p_term = (x(end,2) - x(end,1)) .* (x(end,1) + x(end,2)) ./2;

% Total weighted areal
wa = da .* (l_term + r_term) + p_term;

% normalized by nonweighted area for the centroid
c = wa / fuzzy_area(x);
